
const tabBarDay =  {
    color: '#9299A7',
    selectedColor: '#3C79FF',
    backgroundColor: '#fff'
}

const navigationBarDay = {
    frontColor: '#000000',
    backgroundColor: '#ffffff'
};

const tabBarNight =  {
    color: '#9299A7',
    selectedColor: '#ffffff',
    backgroundColor: '#2B3757'
}

const navigationBarNight = {
    frontColor: '#ffffff', // 导航栏文字设置
    backgroundColor: '#2B3757', // 导航栏背景色设置
};


const state = {
    theme: uni.getStorageSync('theme')? uni.getStorageSync('theme') : 'day-theme',
}

const mutations = {
    GET_THEME(state, theme) {
        state.theme = theme
        let tabBar = theme == 'day-theme' ? tabBarDay : tabBarNight
        let navigationBar = theme == 'day-theme' ? navigationBarDay : navigationBarNight
        uni.setTabBarStyle(tabBar)
        uni.setNavigationBarColor(navigationBar)
        uni.setStorageSync('theme', theme)
        // uni.showToast({
        //     title: '主题切换完成',
        //     icon: 'none'
        // })

    }
}

const actions = {

}

const getters = {
    theme: state => state.theme,
}

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}
